// 发送请求。获取数据
$(function () {
    $(document).ready(function () {
        $.ajax({
            url: '../../static/data/list.json'
        }).done(function (data) {
            // console.log(data)
            let str = ''
            data.list.forEach(function (item, index) {
                str += `
          <li class="shangpin_li" id=${item.list_id}>
                <div class="Product_list_ul_li" >
                <img src="${item.small_img}" alt="" class="Product_img">
                <p class="p1">${item.title}</p>
                <p class="p2">${item.jieshao}</p>
              </div>
              <div class="Product_list_ul_li2">
                <img src="${item.small_img}" alt="" class="Product_img">
                <p class="p1">${item.title}</p>
                <p class="p2">${item.jieshao}</p>
                <p class="p3">${item.jiege}</p>
              </div>
          </li>
                `
            })
            $('.Product_list_ul').html(str)
            // 商品li划入效果
            // console.log($(".shangpin_li").find('.Product_list_ul_li'))
            for (let i = 0; i < $(".shangpin_li").length; i++) {
                $($(".shangpin_li")[i]).mouseover(function () {
                    $($(".shangpin_li")[i]).find('.Product_list_ul_li').css("display", "none")
                    $($(".shangpin_li")[i]).find('.Product_list_ul_li2').css("display", "block")
                })
            }
            // 商品li划出效果
            for (let i = 0; i < $(".shangpin_li").length; i++) {
                $($(".shangpin_li")[i]).mouseout(function () {
                    $($(".shangpin_li")[i]).find('.Product_list_ul_li').css("display", "block")
                    // console.log($($(".shangpin_li")[i]).find('.Product_list_ul_li'))
                    $($(".shangpin_li")[i]).find('.Product_list_ul_li2').css("display", "none")
                })
            }
            // li的点击事件
            for (let i = 0; i < $(".shangpin_li").length; i++) {
                $($(".shangpin_li")[i]).click(function () {
                    // console.log($($(".shangpin_li")[i]).attr("id"))
                    location.href=`./details.html?#id=${$($(".shangpin_li")[i]).attr("id")}`
                    
                })
            }
        })
    })
})